/*
 * @lc app=leetcode.cn id=70 lang=javascript
 *
 * [70] 爬楼梯
 */

// @lc code=start
/**
 * @param {number} n
 * @return {number}
 */
var climbStairs = function(n) {
    //总结规律：爬上n阶台阶的方法相当于爬上n-1和n-2个台阶的方法总和
    let pre = 0,middle = 0,last = 1;
    for(let i=1; i<=n; i++) {
        pre = middle;
        middle = last;
        last = pre + middle;
    }
    return last;
};
// @lc code=end

